

package jetbrains.buildServer.server.graphql.resolver.agentPool;

import java.util.Set;
import jetbrains.buildServer.serverSide.agentPools.AgentPool;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public interface AgentPoolActionsAccessChecker {
  /**
   *
   */
  @Nullable
  ManageAgentsInPoolUnmetRequirements getUnmetRequirementsToManageAgentsInPool(int agentPoolId);

  /**
   * Retrieve a set of visible projects which restrict current user form removing given agent type from its current pool.
   * There may be hidden projects, so canMoveAgentFromItsCurrentPool(id) !== getRestrictingProjectsInAssociatedPool(id).isEmpty().
   */
  @NotNull
  Set<String> getRestrictingProjectsInAssociatedPool(int agentTypeId);

  /**
   * Retrieve a set of visible projects which restrict current user form adding agents to (or removing from) given pool.
   */
  @NotNull
  Set<String> getRestrictingProjectsInPool(int agentPoolId);

  /**
   * Retrieve a set of agent pool ids for pools without projects disallowing user to manage agents assigned with said pools.
   */
  @NotNull
  Set<Integer> getManageablePoolIds();

  /**
   * Check if current user has enough permissions to move some agent to the specified pool.
   * In order to fully check permissions for the move operation, current pool of the desired agent must be checked too.
   */
  boolean canManageAgentsInPool(@NotNull AgentPool targetPool);

  /**
   * Check if current user has enough permissions to add/remove projects to the given pool.
   * In order to fully check permissions for project move both source and target pools must be checked.
   */
  boolean canManageProjectsInPool(int agentPoolId);

  /**
   * Check if current user has enough permissions to modify name and limits of the given pool.
   */
  boolean canModifyAgentPool(int agentPoolId);
}